﻿function chgvalidate(obj){
    var test,val,nm,p,errors;
    test = obj.title;
    val = obj.value;
    nm=obj.id;
    if(test.indexOf('R')!=-1){
        if (val!= "") {
            document.getElementById("s" + nm).innerHTML = '';
            if (test.indexOf('isEmail') != -1) {
                if (Is_Email(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else if (test.indexOf('isNo') != -1) {
                if (isNaN(val)) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            } else if (test.indexOf('isDate') != -1) {
                if (Is_Date(val)==false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else if (test.indexOf('isTime') != -1) {
                if (Is_Time(val)==false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else if (test.indexOf('isMD') != -1) {
                if (Is_MonthDay(val)==false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else if (test.indexOf('isCmb') != -1) {
                if (isNaN(val)) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }
        }else if (test.charAt(0) == 'R') { 
            errors = true; document.getElementById("s" + nm).innerHTML = '*'; 
        }
    }else if(test.indexOf('isEmail')!=-1){
        if (val!= "") {
            if (Is_Email(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
        }else{
            document.getElementById("s" + nm).innerHTML='';
        }
    }else if(test.indexOf('isNo')!=-1){
        if (val!= "") {
            if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
        }else{
            document.getElementById("s" + nm).innerHTML='';
        }
    }else if (test.indexOf('isDate') != -1) {
        if (val!= "") {
            if (Is_Date(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
        }else{
            document.getElementById("s" + nm).innerHTML='';
        }
    }else if (test.indexOf('isTime') != -1) {
        if (val!= "") {
            if (Is_Time(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
        }else{
            document.getElementById("s" + nm).innerHTML='';
        }
    }else if (test.indexOf('isMD') != -1) {
        if (val!= "") {
            if (Is_MonthDay(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
        }else{
            document.getElementById("s" + nm).innerHTML='';
        }
    }else if(test.indexOf('isCmb')!=-1){
        if (val!= "") {
            if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
        }else{
            document.getElementById("s" + nm).innerHTML='';
        }
    }
}

//function trim(s)
//{
//	return rtrim(ltrim(s));
//}

//function ltrim(s)
//{
//	var l=0;
//	while(l < s.length && s[l] == ' ')
//	{	l++; }
//	return s.substring(l, s.length);
//}

//function rtrim(s)
//{
//	var r=s.length -1;
//	while(r > 0 && s[r] == ' ')
//	{	r-=1;	}
//	return s.substring(0, r+1);
//}
function validate(){
    var frm = document.forms[0];
    var test,val,nm,p;
    var errors=false;
    for(var i=0;i<frm.length;i++){
        test = frm[i].title;
        //val = trim(frm[i].value);
        val = (frm[i].value);
        nm=frm[i].id;
        if(test.indexOf('R')!=-1){
            if (val != "") {
             
                document.getElementById("s" + nm).innerHTML = '';
                if (test.indexOf('isEmail') != -1) {
                    if (Is_Email(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isNo') != -1) {
                    if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isDate') != -1) {
                    if (Is_Date(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isTime') != -1) {
                    if (Is_Time(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isMD') != -1) {
                    if (Is_MonthDay(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isCmb') != -1) {
                    if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }
            }else if (test.charAt(0) == 'R') { 
                 errors = true;document.getElementById("s" + nm).innerHTML = '*'; 
            }
        }else if(test.indexOf('isEmail')!=-1){
            if (val!= "") {
                if (Is_Email(val)==false) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if(test.indexOf('isNo')!=-1){
            if (val!= "") {
                if (isNaN(val)) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isDate') != -1) {
            if (val!= "") {
                if (Is_Date(val)==false) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isTime') != -1) {
            if (val!= "") {
                if (Is_Time(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isMD') != -1) {
            if (val!= "") {
                if (Is_MonthDay(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if(test.indexOf('isCmb')!=-1){
            if (val!= "") {
                if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }
    } if (errors) { alert('Please Fill required fileds or correct data.'); return false;}
    else {return true; }
}
function validate1(){
    var frm = document.forms[0];
    var test,val,nm,p;
    var errors=false;
    for(var i=0; i<frm.length;i++){
        test = frm[i].title;
        val = frm[i].value;
        nm=frm[i].id;
        if(test.indexOf('R')!=-1){
            if (val!= "") {
                document.getElementById("s" + nm).innerHTML = '';
                if (test.indexOf('isEmail') != -1) {
                    if (Is_Email(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isNo') != -1) {
                    if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isDate') != -1) {
                    if (Is_Date(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isTime') != -1) {
                    if (Is_Time(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isMD') != -1) {
                    if (Is_MonthDay(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isCmb') != -1) {
                    if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }
            }else if (test.charAt(0) == 'R') { 
                 errors = true;document.getElementById("s" + nm).innerHTML = '*'; 
            }
        }else if(test.indexOf('isEmail')!=-1){
            if (val!= "") {
                if (Is_Email(val)==false) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if(test.indexOf('isNo')!=-1){
            if (val!= "") {
                if (isNaN(val)) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isDate') != -1) {
            if (val!= "") {
                if (Is_Date(val)==false) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isTime') != -1) {
            if (val!= "") {
                if (Is_Time(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isMD') != -1) {
            if (val!= "") {
                if (Is_MonthDay(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if(test.indexOf('isCmb')!=-1){
            if (val!= "") {
                if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }
    } 
}

function Is_Email(email) {
    var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
    var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
    if (!(!reg1.test(email) && reg2.test(email))) return false;
    else return true;
}
function Is_Date(dt){
    var tdate = new Date();
    splitDate = dt.split("/");
    refDate = new Date(splitDate[1]+ "/" + splitDate[0]+"/"+splitDate[2]);
    if (splitDate[1] < 1 || splitDate[1] > 12 || refDate.getDate() != splitDate[0] || splitDate[2].length != 4)
    {
        return false;
    }else{
        if(splitDate[2]<(tdate.getFullYear() -100) || splitDate[2]>(tdate.getFullYear() +100)){
            return false;
        }else{
            return true;
        }
    }
}
function Is_MonthDay(dt){
    splitDate = dt.split("/");
    if (splitDate[1] < 1 || splitDate[1] > 12 || splitDate[0] < 1 || splitDate[0] > 31)
    {
        return false;
    }else{
        return true;
    }
}
function numberonly(){
	var frm = document.forms[0];
    var sel = document.getElementsByTagName("input");
      for(var i=0; i < sel.length;i++){
		  if(sel[i].getAttribute("onkeypress")==null){
            sel[i].setAttribute("onkeypress","return noHTML(this,event)");
		  }
      }
	  var sel = document.getElementsByTagName("textarea");
      for(var i=0; i < sel.length;i++){
		  if(sel[i].getAttribute("onkeypress")==null){
            sel[i].setAttribute("onkeypress","return noHTML(this,event)");
		  }
      }
//    var sel = document.getElementsByTagName("textarea");
//      for(var i=0; i < sel.length;i++){
//      //sel[i].style.width="120px";
//       if(sel[i].title=="isNo" || sel[i].title=="RisNo"){
//        sel[i].setAttribute("onkeypress","return numbersonly(this,event)");
//		}
//      }
//      var sel = document.getElementsByTagName("td");
//      for(var i=0;i<sel.length;i++){
//        //sel[i].setAttribute("width","");
//      //alert(sel[i].innerHTML.indexOf('<input'));
//      //sel[i].style.width="120px";
//        if((sel[i].innerHTML.indexOf('<input')== -1 && sel[i].innerHTML.indexOf('<select')== -1 && sel[i].innerHTML.indexOf('<textarea')== -1 ) && sel[i].innerHTML.indexOf('<img')== -1){
//          if((sel[i].getAttribute("class")!="title") && (sel[i].getAttribute("class")!="menutitle")){
//            sel[i].setAttribute("align","right");
//           // sel[i].style.fontWeight="normal";
//          }
//		}else{       
//		    sel[i].setAttribute("align","left");
//		     //   sel[i].style.fontWeight="bold";
//		}
//      }
//      var sel = document.getElementsByTagName("span");
//      for(var i=0;i<sel.length;i++){
//       if(sel[i].getAttribute("class")=="calender"){
//            sel[i].setAttribute("align","left");
//		}else {
//		if(sel[i].getAttribute("class")=="left" && sel[i].getAttribute("class")!="curTime" ){
//		    sel[i].setAttribute("class","right");
//		    }
//		}
//      }
//    for(var i=0;i<frm.length;i++){
//        if(frm[i].type=='text' || frm[i].type=='password')
//        if(frm[i].title=="RisDate" || frm[i].title=="isDate"){
//            frm[i].style.width="105px";
//            frm[i].setAttribute("onclick","JACS.show(this,event);");
//            frm[i].setAttribute("maxlength","10");
//		}else{
//            frm[i].style.width="120px";
//        }
//        if(frm[i].title=="isNo" || frm[i].title=="RisNo"){
//            frm[i].setAttribute("onkeypress","return numbersonly(this,event)");
//		}
//    }
}
function noHTML(obj,e){
  var unicode=e.charCode? e.charCode : e.keyCode;
  if(unicode==96){alert("Symbol ` is not allowed.");return false;}
  if(unicode==126){alert("Symbol ~ is not allowed.");return false;}
  if(unicode==33){alert("Symbol ! is not allowed.");return false;}
  if(unicode==35){alert("Symbol # is not allowed.");return false;}
  if(unicode==36){alert("Symbol $ is not allowed.");return false;}
  if(unicode==94){alert("Symbol ^ is not allowed.");return false;}
  if(unicode==124){alert("Symbol | is not allowed.");return false;}
}
function numbersonly(obj, e) {
   
    var arrs = [], key = window.event ? event.keyCode : e.keyCode;
    arrs[37] = 'l';
    arrs[38] = 'up';
    arrs[39] = 'r';
    arrs[40] = 'down';

    var unicode=e.charCode? e.charCode : e.keyCode;
	 if(unicode==96){alert("Symbol ` is not allowed.");return false;}
	  if(unicode==126){alert("Symbol ~ is not allowed.");return false;}
	  if(unicode==33){alert("Symbol ! is not allowed.");return false;}
	  if(unicode==35){alert("Symbol # is not allowed.");return false;}
	  if(unicode==36){alert("Symbol $ is not allowed.");return false;}
	  if(unicode==94){alert("Symbol ^ is not allowed.");return false;}
	  if(unicode==124){alert("Symbol | is not allowed.");return false;}
    if(unicode==46){
        if (obj.value.toString().indexOf(".",0)>0){return false}
    } else if (unicode == 9 || ((unicode == 39) && (arrs[key] == "r")) || ((unicode == 37) && (arrs[key] == "l")) || unicode == 46) {
    }else if (unicode!=8){
        if (unicode<48||unicode>57) {return false;}
    }
}


function CharacterAnUnderScoreonly(obj, e) {

    var arrs = [], key = window.event ? event.keyCode : e.keyCode;
        arrs[37] = 'l';
        arrs[38] = 'up';
        arrs[39] = 'r';
        arrs[40] = 'down';

        var unicode = e.charCode ? e.charCode : e.keyCode;
    if (unicode == 96) { alert("Symbol ` is not allowed."); return false; }
    if (unicode == 126) { alert("Symbol ~ is not allowed."); return false; }
    if (unicode == 33) { alert("Symbol ! is not allowed."); return false; }
    if (unicode == 35) { alert("Symbol # is not allowed."); return false; }
    if (unicode == 36) { alert("Symbol $ is not allowed."); return false; }
    if (unicode == 94) { alert("Symbol ^ is not allowed."); return false; }
    if (unicode == 124) { alert("Symbol | is not allowed."); return false; }
 
    if ((unicode >= 65 && unicode <= 90) || (unicode >= 97 && unicode <= 122) || (unicode == 95) || (unicode == 8) || (unicode == 46) || ((unicode == 37) && (arrs[key]=="l")) || ((unicode == 39)&& (arrs[key]=="r")) || (unicode == 9)) {

        }
        else {
            return false;
        }
    }
  

function entersearch(e){
    var unicode=e.charCode? e.charCode : e.keyCode
    if(unicode==13){
        search();
    }
}

function Is_Time(timeStr) {
    var timePat = /^(\d{1,2}):(\d{2})?(\s?(AM|am|PM|pm))?$/;
    var matchArray = timeStr.match(timePat);
    if (matchArray == null) {
        return false;
    }
    hour = matchArray[1];
    minute = matchArray[2];
    ampm = matchArray[3];

    if (hour < 0  || hour > 23) {
        return false;
    }
    if (minute<0 || minute > 59) {
        return false;
    }
    return true;
}


function showOfDiv(div) {
    if(!div) {return;}
    div = typeof div === "string" ? document.getElementById(div) : div;
    var elms = div.getElementsByTagName("*");
    for(var i = 0, maxI = elms.length; i < maxI; ++i) {
        if(elms[i].type=="text" || elms[i].type=="select-one"){
            elms[i].focus();
            break;
        }
    }
    validate1();
    numberonly();
}

function tabpress(e,exp){
    var unicode=e.charCode? e.charCode : e.keyCode;
    if(unicode==9){setTimeout(exp,0);}
}

function replacehash(val){
    var str= val.toString().replace(/#/g,"!11!");
    str = str.toString().replace(/&/g,"!22!");
    str = str.toString().replace(/\+/g,"!33!");
    return str;
}
//function arrHasDupes(A) {
//	var i, j, n;
//	n=A.length;                  
//	for (i=0; i<n; i++) {
//	    for (j = i + 1; j < n; j++) {
//		    if (A[i] != "" && A[j]!="") {         
//			    if (A[i]==A[j]) return false;
//                                        }
//	                                }	
//	                    }
//	    return true;
//    }
function arrHasDupes(A) {
    //This Function is used In semester setup and batch Setup
        var i, j, n;
        n = A.length;
        for (i = 0; i < n; i++) {
            for (j = i + 1; j < n; j++) {
                if (A[i] != "" && A[j] != "") {
                    if (A[i].toUpperCase() == A[j].toUpperCase()) return false;
                }
            }
        }
        return true;
    }
    
function arrHasDupes1(A) {
    var i, j, n;
    n = A.length;
    for (i = 0; i < n; i++) {
        for (j = i + 1; j < n; j++) {
            if (A[i] == A[j]) return false;
        }
    }
    return true;
}
function validatediv(frmid){
    if(!frmid) {return;}
    frmid = typeof frmid === "string" ? document.getElementById(frmid) : frmid;
    var frm = frmid.getElementsByTagName("*");
    var test,val,nm,p;
    var errors=false;
    for(var i=0; i<frm.length;i++){
        test = frm[i].title;
        val = frm[i].value;
        nm=frm[i].id;
        if(test.indexOf('R')!=-1){
            if (val!= "") {
                document.getElementById("s" + nm).innerHTML = '';
                if (test.indexOf('isEmail') != -1) {
                    if (Is_Email(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isNo') != -1) {
                    if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isDate') != -1) {
                    if (Is_Date(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isTime') != -1) {
                    if (Is_Time(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isMD') != -1) {
                    if (Is_MonthDay(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }else if (test.indexOf('isCmb') != -1) {
                    if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }
            }else if (test.charAt(0) == 'R') { 
                 errors = true;document.getElementById("s" + nm).innerHTML = '*'; 
            }
        }else if(test.indexOf('isEmail')!=-1){
            if (val!= "") {
                if (Is_Email(val)==false) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if(test.indexOf('isNo')!=-1){
            if (val!= "") {
                if (isNaN(val)) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isDate') != -1) {
            if (val!= "") {
                if (Is_Date(val)==false) {  errors = true;document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isTime') != -1) {
            if (val!= "") {
                if (Is_Time(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if (test.indexOf('isMD') != -1) {
            if (val!= "") {
                if (Is_MonthDay(val)==false) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }else if(test.indexOf('isCmb')!=-1){
            if (val!= "") {
                if (isNaN(val)) {  errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            }else{
                document.getElementById("s" + nm).innerHTML='';
            }
        }
    } if (errors) {  alert('Please Fill required fileds or correct data.'); return false;}
    else {return true; }
}


function chkRequired() {
    var frm = document.forms[0];
    var test, val, nm, p;
    var errors = false;
    for (var i = 0; i < frm.length; i++) {
        test = frm[i].getAttribute('isRequired');
        //val = trim(frm[i].value);
        val = (frm[i].value);
        nm = frm[i].id;
        if (test.indexOf('R') != -1) {
            if (val != "") {
                document.getElementById("s" + nm).innerHTML = '';
                if (test.indexOf('isEmail') != -1) {
                    if (Is_Email(val) == false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isNo') != -1) {
                    if (isNaN(val)) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isDate') != -1) {
                    if (Is_Date(val) == false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isTime') != -1) {
                    if (Is_Time(val) == false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isMD') != -1) {
                    if (Is_MonthDay(val) == false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                } else if (test.indexOf('isCmb') != -1) {
                    if (isNaN(val)) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
                }
            } else if (test.charAt(0) == 'R') {
                errors = true; document.getElementById("s" + nm).innerHTML = '*';
            }
        } else if (test.indexOf('isEmail') != -1) {
            if (val != "") {
                if (Is_Email(val) == false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Email Id'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            } else {
                document.getElementById("s" + nm).innerHTML = '';
            }
        } else if (test.indexOf('isNo') != -1) {
            if (val != "") {
                if (isNaN(val)) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Fill numeric value'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            } else {
                document.getElementById("s" + nm).innerHTML = '';
            }
        } else if (test.indexOf('isDate') != -1) {
            if (val != "") {
                if (Is_Date(val) == false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Date'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            } else {
                document.getElementById("s" + nm).innerHTML = '';
            }
        } else if (test.indexOf('isTime') != -1) {
            if (val != "") {
                if (Is_Time(val) == false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid Time'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            } else {
                document.getElementById("s" + nm).innerHTML = '';
            }
        } else if (test.indexOf('isMD') != -1) {
            if (val != "") {
                if (Is_MonthDay(val) == false) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            } else {
                document.getElementById("s" + nm).innerHTML = '';
            }
        } else if (test.indexOf('isCmb') != -1) {
            if (val != "") {
                if (isNaN(val)) { errors = true; document.getElementById("s" + nm).innerHTML = '<br>Invalid'; } else { document.getElementById("s" + nm).innerHTML = ''; }
            } else {
                document.getElementById("s" + nm).innerHTML = '';
            }
        }
    } if (errors) { alert('Please Fill required fileds or correct data.'); return false; }
    else { return true; }
}